$(function () {
    //省市弹出框
    var cityPicker = new mui.PopPicker({layer:3});
    
    cityPicker.setData(cityData);  //数组
   
    var showCityPickerButton = document.getElementById("showCityPicker");
   
    console.log(showCityPickerButton);
    //获取dom的showCityPickerButton  是dom对象所以要转zepto 对象 里面不能传对象不能带引号
    $(showCityPickerButton).on('tap',function (event) {
       //console.log(event);
    
        cityPicker.show (function (items) {
            $('[name="address"]').val((items[0] || {}).text + (items[1] || {}).text + (items[2] || {}).text);
        }, false);
    })
    
   //  点击 '确认按钮'
   //获取input中的val()值
   //发送ajax请求
    var recipients =$.trim($('[name="recipients"]')); 
    console.log(recipients);
    var postcode = $.trim($('[name="postcode"]')); 
    var address = $.trim($('[name="address"]')); 
    var addressDetail = $.trim($('[name="addressDetail"]')); 

    $("#box").on('tap','span',function () {  //给其父元素 注册点击事件 子元素可以使用点击事件
        $.ajax({
            url:'/address/addAddress',
            type:'post',
            data:{
                address:'address',
                addressDetail:'addressDetail',
                recipients:'recipients',
                postcode:'postcode'
            },
            success:function (result) {
                   console.log(result);
                   //result  要返回当前的状态值  如果是success:true则 成功
                   setInterval(function () {
                       location.href = "address.html";
                   },2000);
            }

        });
    });

});

